import Base from 'models/base';

import SystemUtil from 'utils/systemUtil';

export default class GoodsEvaluat extends Base {
  static scoreTextData = {
    "1": "非常差",
    "2": "差",
    "3": "一般",
    "4": "好",
    "5": "非常好"
  };
  remark = '';
  evaluatPicList = [];
  score = 5;
  tasteScore = 5;
  packScore = 5;

  constructor(goods) {
    super();

    let fields = ['orderId', 'orderNoSub', 'defId', 'modelId', 'name', 'modelName', 'pic', 'branchId', 'partnerId'];
    this.initObject(goods, fields);
  }

  getObject() {
    let postData = {
      orderNoMain: this.orderId,
      orderNoSub: this.orderNoSub,
      goodsDefId: this.defId,
      goodsModelId: this.modelId,
      branchId: this.branchId,
      appraiseMsg: this.remark,
      appraiseScore: this.score * 2,
      appraisePackScore: this.packScore * 2,
      appraiseTasteScore: this.tasteScore * 2
    };

    let partnerId = this.partnerId;
    if (!SystemUtil.isEmpty(partnerId)) {
      postData.partnerId = partnerId;
    }

    let evaluatPicList = this.evaluatPicList;
    if (evaluatPicList.length === 0) {
      postData.appraisePic = '';
    } else {
      postData.appraisePic = JSON.stringify(evaluatPicList);
    }

    return postData;
  }
}
